package com.test3;

import javax.xml.namespace.QName;

/**
 * @author cjx
 * @create 2024/06/12
 * @description
 */
public class Car {
    private String name;
    private String color;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public Car() {
    }

    public Car(String name, String color) {
        this.name = name;
        this.color = color;
    }

    // 成员内部类
    public class Engine {
        private String pronum;
        private String proyear;

        static String speed;

        public Engine() {
        }

        public Engine(String pronum, String proyear, String speed) {
            this.pronum = pronum;
            this.proyear = proyear;
            this.speed = speed;
        }

        public void sout() {
            System.out.println("生产编号：" + pronum + "," + "生产日期：" + proyear);
        }

        public static void speedRun() {
            System.out.println("转速" + speed);
        }
    }

    public Engine getInstance(String pronum, String proyear, String speed) {
        return  new Engine(pronum, proyear, speed);
    }

    // 静态内部类
    public static class Engine2 {
        public static void sout() {
            System.out.println("品牌：" + new Car().getName() + "生产日期：" + new Car().getColor());
        }
    }

    // 局部匿名内部类
    public void driver() {
        ((Repair) () -> System.out.println("去修理")).goRepair();
        
        new Repair() {
            @Override
            public void goRepair() {
                System.out.println("去修理");
            }
        }.goRepair();

        Engine eng = new Engine() {
            final String name = "无敌";
            final String color = "红色";

            @Override
            public void sout() {
                System.out.println(name + color);
            }
        };

        eng.sout();
    }
}
